import requestMeeting, { request } from '@/plugins/axios'
import { Mt, MtEntity } from '../mt'
import { makeMtParam } from '../type'
import { transVipList } from './translator'

export const fetchVipList = async (meetingMoid: string) =>
	requestMeeting<MtEntity[]>({
		url: `/mcc/${meetingMoid}/vip`,
		method: 'get',
	}).then((res) => (res.success && res.data ? transVipList(res.data) : undefined))

export const fetchSaveVipList = async (meetingMoid: string, mts: Mt[]) =>
	request({
		url: `/mcc/${meetingMoid}/vip`,
		method: 'POST',
		data: mts.map((x) => makeMtParam(x)),
	}).then((res) => res.success)
